package de.koller.aframe.gl;

import de.koller.oceanFramework.gl.util.ParticleTexture;
import de.koller.oceanFramework.gl.util.RasterManager;
import java.nio.ByteBuffer;
import org.lwjgl.opengl.GL11;

public class Utils {

	private Utils() {}
	
	public static void loadTextureData( ParticleTexture out, int w, int h ) {
		ByteBuffer b = ByteBuffer.allocateDirect( w*h*4 );
		GL11.glGetTexImage( GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, b );
		for( int i = 0; i < w*h*4; i++)
			out.getData()[i] = b.get();
		out.flipHorizontal();
		out.flush();
	}
	
	public static void loadTextureData( ParticleTexture out ) {
		loadTextureData( out, out.getWidth(), out.getHeight() );
	}
	
	public static void copyRaster( RasterManager src, RasterManager dst ) {
		System.arraycopy( src.getData(), 0, dst.getData(), 0, src.getData().length );
	}
	
}
